home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / lib / tk / tkerror.tcl < prev   
Text File  |  1995-07-21  |  1KB  |  40 lines

  1. # This file contains a default version of the tkError procedure.  It
  2. # posts a dialog box with the error message and gives the user a chance
  3. # to see a more detailed stack trace.
  4.  
  5. proc tkerror err {
  6.     global errorInfo
  7.     set info $errorInfo
  8.     if {[tk_dialog .tkerrorDialog "Error in Tcl Script" \
  9.         "Error: $err" error 0 OK "See Stack Trace"] == 0} {
  10.     return
  11.     }
  12.  
  13.     set w .tkerrorTrace
  14.     catch {destroy $w}
  15.     toplevel $w -class ErrorTrace
  16.     wm minsize $w 1 1
  17.     wm title $w "Stack Trace for Error"
  18.     wm iconname $w "Stack Trace"
  19.     button $w.ok -text OK -command "destroy $w"
  20.     text $w.text -relief raised -bd 2 -yscrollcommand "$w.scroll set" \
  21.         -setgrid true -width 40 -height 10
  22.     scrollbar $w.scroll -relief flat -command "$w.text yview"
  23.     pack $w.ok -side bottom -padx 3m -pady 3m -ipadx 2m -ipady 1m
  24.     pack $w.scroll -side right -fill y
  25.     pack $w.text -side left -expand yes -fill both
  26.     $w.text insert 0.0 $info
  27.     $w.text mark set insert 0.0
  28.  
  29.     # Center the window on the screen.
  30.  
  31.     wm withdraw $w
  32.     update idletasks
  33.     set x [expr [winfo screenwidth $w]/2 - [winfo reqwidth $w]/2 \
  34.         - [winfo vrootx [winfo parent $w]]]
  35.     set y [expr [winfo screenheight $w]/2 - [winfo reqheight $w]/2 \
  36.         - [winfo vrooty [winfo parent $w]]]
  37.     wm geom $w +$x+$y
  38.     wm deiconify $w
  39. }
  40.